import requests

class BookAPI:
    def __init__(self, base_url="http://127.0.0.1:8000/books"):
        self.base_url = base_url

    def get_book(self):
        """Get all books information"""
        response = requests.get(self.base_url)
        return response.json()

    def post_book(self):
        """Create a new book"""
        title = input("Enter book title: ")
        author = input("Enter book author: ")
        category = input("Enter book category: ")
        book_data = {
            "title": title,
            "author": author,
            "category": category
        }
        response = requests.post(f"{self.base_url}/create_book", json=book_data)
        return response.json()

    def put_book(self):
        """Update an existing book"""
        title = input("Enter book title: ")
        author = input("Enter book author: ")
        category = input("Enter book category: ")
        book_data = {
            "title": title,
            "author": author,
            "category": category
        }
        response = requests.put(f"{self.base_url}/update_book", json=book_data)
        return response.json()

    def delete_book(self):
        """Delete a book by title"""
        book_title = input("Enter book title: ")
        response = requests.delete(f"{self.base_url}/delete_book/{book_title}")
        return response.json()

if __name__ == "__main__":
    api = BookAPI()
    print(api.get_book())